#ifndef __INPUTHANDLE_H__
#define __INPUTHANDLE_H__
#include <iostream>
#include <SDL.h>
#include "Vector2D.h"

enum mouse_buttons{
    MOUSE_LEFT = 0,
    MOUSE_MIDDLE = 1,
    MOUSE_RIGHT = 2
}; 

class InputHandler{
    public:
        static InputHandler * Instance(){
            if (s_pInstance == nullptr){
                s_pInstance = new InputHandler();
            }
            return s_pInstance;
        }

        void initialiseJoysticks();
        bool joysticksInitialised(){
            return m_bJoysticksInitialised;
        }

        bool getMouseButtonState(int buttonNumber){
            return m_mouseButtonStates[buttonNumber];
        }

        Vector2D * getMousePosition(){
            return m_mousePosition;
        }

        bool isKeyDown(SDL_Scancode key);
        void reset(){};

        void update();
        void clean();

    private:
        InputHandler();
        ~InputHandler();
        static InputHandler * s_pInstance;

        bool m_bJoysticksInitialised;
        std::vector<SDL_Joystick*> m_joysticks;
        std::vector<bool> m_mouseButtonStates;//deal mouse button
        Vector2D * m_mousePosition;           //deal mouse motion
        uint8_t * m_keystates;
};

typedef InputHandler TheInputHandler;

#endif
